﻿@using System.Data;
@using System.Web;
@using DTcms.Web.MVC.Areas.Web.Controllers;
@using DTcms.Web.MVC.UI.Controllers;
@using DTcms.Model;
@{
   Layout = "~/Areas/Web/Views/" + ViewBag.TemplateSkin + "/Shared/_Layout.cshtml";
   DTcms.Model.sites site = ViewData["site"] as DTcms.Model.sites;
   DTcms.Model.sysconfig config = ViewData["sysConfig"] as DTcms.Model.sysconfig;
   BaseController bc = ViewBag.BasePage as BaseController;
   UserController c = ViewBag.This as UserController;
   DTcms.Model.users m = c.userModel;
   ViewBag.Title = "我的订单 - " + site.name;
   string action = ViewBag.Action as string;
   DataTable list = null;
   int count = 0;
   int totalcount = 0;
   int page = int.Parse(ViewBag.Page as string);
   string pagelist = string.Empty;
   string user_avatar = string.Empty;
}

<!--当前位置-->
<div class="section">
  <div class="location">
    <span>当前位置：</span>
    <a href="@bc.linkurl("index")">首页</a> &gt;
        <a href="@bc.linkurl("usercenter", "index")">会员中心</a>
    <a href="@bc.linkurl("userorder", "list")">我的订单</a>
  </div>
</div>
<!--/当前位置-->

<div class="section clearfix">
  <!--左侧导航-->
  @RenderPage("~/Areas/Web/Views/" + ViewBag.TemplateSkin + "/Shared/partial_ucenter_nav.cshtml")
  <!--/左侧导航-->




  <!--右侧内容-->
  <div class="right-auto">
    <div class="bg-wrap" style="min-height: 765px;">
      @if (action == "list") {
        <!--交易订单-->
        <div class="sub-tit">
          <a class="add" href="javascript:history.go(-1);"><i class="iconfont icon-reply"></i>返回</a>
          <ul>
            <li class="selected">
              <a href="@bc.linkurl("userorder", "list")">交易订单</a>
            </li>
            <li>
              <a href="@bc.linkurl("userorder", "close")">已关闭订单</a>
            </li>
          </ul>
        </div>
        <div class="table-wrap">
          <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ftable">
            <tr>
              <th width="16%" align="left">订单号</th>
              <th align="left">订单商品</th>
              <th width="10%">姓名</th>
              <th width="12%">订单金额</th>
              <th width="11%">下单时间</th>
              <th width="10%">状态</th>
              <th width="12%">操作</th>
            </tr>
            @{ 
        list = bc.get_order_list(10, page, "user_id=" + m.id + " and status<=3", out totalcount); <!--取得一个DataTable-->
        pagelist = bc.get_page_link(10, page, totalcount, "userorder", action, "__id__"); <!--取得分页页码列表-->
            }
            @foreach (DataRow dr in list.Rows) {
              <tr>
                <td>@dr["order_no"]</td>
                <td>
                  @{ List<DTcms.Model.article> ls = bc.get_order_goods_list(Convert.ToInt32(dr["id"]));}
                  @if (ls != null) {
                    foreach (DTcms.Model.article mt in ls) {
                    <a target="_blank" title="@mt.title" href="@bc.linkurl("goods_show", mt.id)">
                      <img width="60" height="60" alt="@mt.title" src="@mt.img_url" class="img">
                    </a>
                 }
                  }
                </td>
                <td align="center">@dr["accept_name"]</td>
                <td align="center"><strong>￥@dr["order_amount"]</strong><br />@bc.get_payment_title(Convert.ToInt32(dr["payment_id"]))</td>
                <td align="center">@dr["add_time"]</td>
                <td align="center">
                  @bc.get_order_status(Convert.ToInt32(dr["id"]))
                </td>
                <td align="center">
                  <a href="@bc.linkurl("userorder_show", dr["id"])">查看订单</a><br />
                  @if (bc.get_order_payment_status(Convert.ToInt32(dr["id"]))) {
                    <a href="@bc.linkurl("payment", "?action=confirm&order_no=" + dr["order_no"])">去付款</a> <span>|</span>
                  }
                  @if (Convert.ToInt32(dr["status"]) < 2) {
                    <a href="javascript:;" onclick="clickSubmit('@(config.webpath)tools/submit_ajax.ashx?action=order_cancel&order_no=@dr["order_no"]');">取消</a>
                  }
                </td>
              </tr>
            }

            @if (totalcount == 0) {
              <tr>
                <td colspan="8" align="center">暂无记录</td>
              </tr>
            }
          </table>
          <div class="page-foot">
            <div class="flickr right">@Html.Raw(pagelist)</div>
            <!--放置页码列表-->
          </div>
        </div>
        <!--/交易订单-->
      
      }

      @if (action == "close") {
        <!--已关闭订单-->
        <div class="sub-tit">
          <a class="add" href="javascript:history.go(-1);"><i class="iconfont icon-reply"></i>返回</a>
          <ul>
            <li>
              <a href="@bc.linkurl("userorder", "list")">交易订单</a>
            </li>
            <li class="selected">
              <a href="@bc.linkurl("userorder", "close")">已关闭订单</a>
            </li>
          </ul>
        </div>
        <div class="table-wrap">

          <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ftable">
            <tr>
              <th width="16%" align="left">订单号</th>
              <th align="left">订单商品</th>
              <th width="10%">姓名</th>
              <th width="12%">订单金额</th>
              <th width="11%">下单时间</th>
              <th width="10%">状态</th>
              <th width="12%">操作</th>
            </tr>
            @{ 
        list = bc.get_order_list(10, page, "user_id=" + m.id + " and status>3", out totalcount); <!--取得一个DataTable-->
        pagelist = bc.get_page_link(10, page, totalcount, "userorder", action, "__id__"); <!--取得分页页码列表-->
            }
            @foreach (DataRow dr2 in list.Rows) {
              <tr>
                <td>@dr2["order_no"]</td>
                <td>
                  @{ List<DTcms.Model.article> ls2 = bc.get_order_goods_list(Convert.ToInt32(dr2["id"]));}
                  @if (ls2 != null) {
                    foreach (DTcms.Model.article mt in ls2) {
                    <a target="_blank" title="@mt.title" href="@bc.linkurl("goods_show", mt.id)">
                      <img width="60" height="60" alt="@mt.title" src="@mt.img_url"></a>
                 }
                  }
                </td>
                <td align="center">@dr2["accept_name"]</td>
                <td align="center"><strong>￥@dr2["order_amount"]</strong><br />@bc.get_payment_title(Convert.ToInt32(dr2["payment_id"]))</td>
                <td align="center">@dr2["add_time"]</td>
                <td align="center">@bc.get_order_status(Convert.ToInt32(dr2["id"]))</td>
                <td align="center"><a href="@bc.linkurl("userorder_show", dr2["id"])">查看订单</a></td>
              </tr>
            }
            @if (totalcount == 0) {
              <tr>
                <td colspan="8" align="center">暂无记录</td>
              </tr>
            }
          </table>

          <div class="page-foot">
            <div class="flickr right">@Html.Raw(pagelist)</div>
            <!--放置页码列表-->
          </div>
        </div>
        <!--/已关闭订单-->
      }
    </div>
  </div>
  <!--/右侧内容-->

</div>
